﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace app
{
    /// <summary>
    /// MainWindow.xaml에 대한 상호 작용 논리
    /// </summary>
    public partial class MainWindow : Window
    {
        ViewModel m_ViewModel;
        Image img = new Image();

        public MainWindow()
        {
            InitializeComponent();
            m_ViewModel = (ViewModel)grid.DataContext;
            m_ViewModel.startWatch();
        }

        private void Click_LoadImage(object sender, RoutedEventArgs e)
        {
            m_ViewModel.imageLoadToFile();
        }

        private void Click_SaveImage(object sender, RoutedEventArgs e)
        {
            m_ViewModel.imageSaveAsFile(this.mainImg);
        }

        //private Clock clock;
        //private ImageFileRead imageFileRead;

        //ViewModel m_ViewModel;

        //public MainWindow()
        //{
        //    InitializeComponent();
        //    m_ViewModel = (ViewModel)grid.DataContext;
        //}

        //delegate void Work();
        //private void Click_LoadImage(object sender, RoutedEventArgs e)
        //{
        //    //Dispatcher.Invoke(DispatcherPriority.Normal, new Work(WorkOne));
        //    m_ViewModel.startWatch();
            
        //    //imageFileRead.OpenToImageFile();
        //}
        //private void WorkOne()
        //{
        //    if (but1.CheckAccess())
        //    {
        //        but1.Content = "파일에서";
        //    }
        //}

        //private void Click_ChangeImage(object sender, RoutedEventArgs e)
        //{
        //    //미구현
        //}

        private void Click_CloseWindow(object sender, RoutedEventArgs e)
        {
            Close();        //윈도우를 종료한다.
        }

        private void GrayImageCreate(object sender, RoutedEventArgs e)
        {
            m_ViewModel.GrayimageCreate();
        }

        private void ColorImageCreate(object sender, RoutedEventArgs e)
        {
            m_ViewModel.ColorimageCreate();
        }
    }
}
